<%@ include file="../inc/common.jsp"%>
<!DOCTYPE HTML>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<title>系统管理员列表</title>
<style>
	.page{margin-top:5px;border-top: 1px solid #DDDDDD;padding: 2px;border-bottom: 1px solid #DDDDDD;font-family: inherit;font-size: 11px;}
	.page a{border:1px solid #DDDDDD;text-align: center;}
	.page a:HOVER{text-decoration: none;font-color: white;}
	.current{background:#23B300;color:white; display: inline-block;height:19px ;width:19px;}
	.num{display: inline-block;height:19px ;width:19px;}
</style>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 系统管理员管理 <span class="c-gray en">&gt;</span> 系统管理员列表<a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="pd-20">
	<div class="text-c"> <!-- 日期范围： -->
		<!-- <input type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}'})" id="datemin" class="input-text Wdate" style="width:120px;">
		-
		<input type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d'})" id="datemax" class="input-text Wdate" style="width:120px;"> -->
		<form action="/administrator/search.htm" method="POST">
			<input type="text" class="input-text" style="width:250px" placeholder="输入系统管理员姓名" id="" name="name" value="${name}">
			<button type="submit" class="btn btn-success" ><i class="Hui-iconfont">&#xe665;</i> 搜索系统管理员</button>
		</form>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l">
	<a href="javascript:;" onclick="batchDelete()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> 
	<a href="/administrator/add.htm"  class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i>点击新增系统管理员</a></span> <span class="r">共有数据：<strong>${page.allCount}</strong> 条</span> </div>
	<table class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="12">系统管理员列表</th>
			</tr>
			<tr class="text-c">
				<th width="25"><input type="checkbox"  /></th>
				<th width="90">姓名</th>
				<th width="90">用户名</th>
                <th>性别</th>
                <th width="150">邮箱</th>
				<th>手机</th>
				<th>级别</th>
				<th width="130">创建时间</th>
				<th width="130">更新时间</th>
				<th width="100">操作</th>
			</tr>
		</thead>
		<tbody>
			<s:if test="page.allCount!=0">
			<s:iterator value="page.records" >
			<tr class="text-c">
				<td><input type="checkbox" value="${id}" name="ids"></td>
				<td>${name}</td>
				<td>${username }</td>
                <td>${gender }</td>
                <td>${email }</td>
                <td>${telphone }</td>
                <s:if test="level==1">
                <td> 超级管理员</td>
                </s:if>
                <s:elseif test="level==2">
                <td>院系管理员</td>
                </s:elseif>
                <s:elseif test="level==3">
                <td> 教师管理员</td>
                </s:elseif>
                <s:elseif test="level==4">
                <td>  临时管理员</td>
                </s:elseif>
				<td>${createTimeStr }</td>
				<td>${lastAccessStr }</td>

				<td class="td-manage"><!-- <a style="text-decoration: none"
					onClick="admin_stop(this,'10001')" href="javascript:;"
					title="停用"><i class="Hui-iconfont">&#xe631;</i></a> -->
					 <a title="编辑" href="/administrator/edit.htm?id=${id}"
					class="ml-5" style="text-decoration: none"><i
						class="Hui-iconfont">&#xe6df;</i></a> <a title="删除"
					href="javascript:;" onclick="deleteOne('/administrator/delete.htm?id=${id}',this)" class="ml-5"
					style="text-decoration: none"><i class="Hui-iconfont">&#xe6e2;</i></a>
				</td>
						</tr>
			</s:iterator>
				</s:if>
				<s:else>
					<tr class="text-c">
						<td style="text-align: center;" colspan="12">暂无数据!</td>
					</tr>
				</s:else>
		</tbody>
	</table>
<div class="page">
		${page.pageCententHTML}
</div>
</div>
<script type="text/javascript">
function admin_add(title,url,w,h){
	layer_show(title,url,w,h);
}
/*管理员-删除*/
function admin_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		
		$(obj).parents("tr").remove();
		layer.msg('已删除!',{icon:1,time:1000});
	});
}
/*管理员-编辑*/
function admin_edit(title,url,id,w,h){
	layer_show(title,url,w,h);
}
/*管理员-停用*/
function admin_stop(obj,id){
	layer.confirm('确认要停用吗？',function(index){
		//此处请求后台程序，下方是成功后的前台处理……
		
		$(obj).parents("tr").find(".td-manage").prepend('<a onClick="admin_start(this,id)" href="javascript:;" title="启用" style="text-decoration:none"><i class="Hui-iconfont">&#xe615;</i></a>');
		$(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">已禁用</span>');
		$(obj).remove();
		layer.msg('已停用!',{icon: 5,time:1000});
	});
}

/*管理员-启用*/
function admin_start(obj,id){
	layer.confirm('确认要启用吗？',function(index){
		//此处请求后台程序，下方是成功后的前台处理……
		
		
		$(obj).parents("tr").find(".td-manage").prepend('<a onClick="admin_stop(this,id)" href="javascript:;" title="停用" style="text-decoration:none"><i class="Hui-iconfont">&#xe631;</i></a>');
		$(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
		$(obj).remove();
		layer.msg('已启用!', {icon: 6,time:1000});
	});
}

/**
 * 单删除
 */
function deleteOne(url,obj) 
{
	layer.confirm('确认要删除该条数据吗？', function(index)
	{
		$.ajax({
		     type: 'POST',
		     url: url ,
		    success:function(data)
			{ 
		    	if(data=="success")
		    	{
					$(obj).parents("tr").remove();
					layer.msg('已删除!', {
						icon : 1,
						time : 1000
					});
					javascript:location.replace(location.href);
		    	}
		    }
		});
	});
}
/**
 * 批量删除
 */
function batchDelete()
{
	var id = [];
	$("table input[name='ids']").each(function()
	{
		if($(this).is(':checked'))
		{
			id.push($(this).val());
		}
	});
	if(id.length==0) 
	{
		layer.alert('请至少选择一条数据');
		return;
	}
	var ids = "";
	for(var i = 0;i<id.length;i++)
	{
		ids = ids +id[i]+","
	}
	layer.confirm('确认要删除选中的吗？', function(index)
	{
		$.ajax({
		     type: 'POST',
		     url: "/administrator/batchDelete.htm",
		     data:{"ids":ids},
		    success:function(data)
			{ 
		    	if(data=="success")
		    	{
					layer.msg('已删除!', 
					{
						icon : 1,
						time : 1000
					});
					javascript:location.replace(location.href);
		    	}
		    }
		});
	});
}
</script>
</body>
</html>